<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*------------------------------
  Programmer: Nguyen Dang Khoa
------------------------------*/

class Cpanel extends Controller {

	function Cpanel()
	{
		parent::Controller();
	}
	
	function index()
	{
		$data['icon']="";
		$data['title']="";
		$data['content']=$this->load->view('main','',true);
		$this->load->view('template',$data);
	}
	function editbanner($id='')
	{
		if($id!='')
		{
			$data['id']=$id; // update
			$result=$this->general_model->get_all_slideshow($id);	
				
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['banners']=$_data;	
		}
		else
			$data['id']=''; // add new
			
		
		$data['content']=$this->load->view('editbanner',$data,true);
		$this->load->view('template',$data);
	}
	// ADD or UPDATE ACTION
	function banner_manipulate()
	{
		if ($this->general_model->banner_manipulate($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/bannermanager/");
	}
	function bannermanager()
	{
		$result=$this->general_model->get_all_slideshow();	
				
		$_data=array();
		if($result->num_rows()>0)
		{
			$_data=$result->result_array();
		}
		$data['banners']=$_data;	
		$data['content']=$this->load->view('banner',$data,true);

		$this->load->view('template',$data);	
	}

// DOWNLOAD ===================	
	function subscribers()
	{
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/downloadmanager/';
		$config['per_page'] = 10;//$this->config->item('item_per_page');
		$config['uri_segment'] = 4; 
		$config['total_rows'] =$this->general_model->get_subscribers_manager('totalrows');
		$this->pagination->initialize($config);
		$result=$this->general_model->get_subscribers_manager('',$config['per_page'],$this->uri->segment(4));
		$temp=array();
			if($result->num_rows()>0)
			{
				$temp=$result->result_array();
			}
		$alldata['banners']=$temp;		
		$alldata['all_link']=$this->pagination->create_links();
		
		$data['content']=$this->load->view('subscribers',$alldata,true);

		$this->load->view('template',$data);					
	}
	function deletesubscriber($id=0)
	{
		$this->db->trans_start(); 
		$this->db->delete('subscribers', array('id' => $id));		
		$this->db->trans_complete();
		redirect("/adminpage/cpanel/subscribers/");
	}
// ============ EVENTS ===================	
	function mailtemplate()
	{
		//echo strtotime("05-13-2011","%m-%d-%Y");
		//echo strtotime("05/16/2011");
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/mailtemplate/';
		$config['per_page'] = 10;//$this->config->item('item_per_page');
		$config['uri_segment'] = 4; 
		$config['total_rows'] =$this->general_model->get_mailtemplate('totalrows');
		$this->pagination->initialize($config);
		$result=$this->general_model->get_mailtemplate('',$config['per_page'],$this->uri->segment(4));
		$temp=array();
			if($result->num_rows()>0)
			{
				$temp=$result->result_array();
			}
		$alldata['banners']=$temp;		
		$alldata['all_link']=$this->pagination->create_links();
		
		$data['content']=$this->load->view('mailtemplate',$alldata,true);

		$this->load->view('template',$data);
		
			
	}
	function editmailtemplate($id='')
	{
		if($id!='')
		{
			$data['id']=$id; // update
			$result=$this->general_model->get_mailtemplate_detail($id);	
				
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['banners']=$_data;	
			
		}
		else
		{
			$data['id']=''; // add new
		}

		$data['content']=$this->load->view('editmailtemplate',$data,true);
		$this->load->view('template',$data);
	}
	// ADD or UPDATE ACTION
	function mailtemplate_manipulate()
	{
		//echo strtotime($_POST['txtStartDate']);
		//die;
		if ($this->general_model->mailtemplate_manipulate($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/mailtemplate/");
	}
	function deleteemailtemplate($id=0)
	{
		$this->db->trans_start(); 
		$this->db->delete('newsletters', array('id' => $id));
		$this->db->trans_complete();
		redirect("/adminpage/cpanel/mailtemplate/");
	}
	function sendmailtemplate($id=0)
	{
		if($id!='')
		{
			$data['id']=$id; // update
			$result=$this->general_model->get_allsubscribers();			
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['banners']=$_data;	
			
		}
		else
		{
			redirect("/adminpage/cpanel/mailtemplate/");
		}

		$data['content']=$this->load->view('selectsubscribers',$data,true);
		$this->load->view('template',$data);
	}
	function action_sendmailtemplate()
	{
		$templateID=$_POST['currentid'];
		$sql ="SELECT title,body,image,id from newsletters where id=".$templateID;
		$query = $this->db->query($sql);
		foreach ($query->result() as $row)
		{
			$body=$row->body;
			$image=$row->image;
			$title=$row->title;
		}
		//echo $body;
		
		$data['body']=$body;
		$data['image']=$image;
		$idlist='';
		if(isset($_POST['check']))
		{
			$n=count($_POST['check']);
			$i=1;
			foreach($_POST['check'] as $m)
			{
				if($i==$n)
				{
					$idlist.= $m;
				}
				else
				{
					$idlist.= $m.",";
				}
				$i++;
			}
		}
		else
		{
			redirect("/adminpage/cpanel/mailtemplate/");	
		}
		$this->load->library('email');
				
		$config = array(
		//	'protocol' => 'smtp',
		//	'smtp_host' => 'ideabox.com.au',
		//	'smtp_user' => 'matt@ideabox.com.au',
		//	'smtp_pass' => 'matt123',
			'mailtype' => 'html',
		);
		
		$this->email->initialize($config);
		if($idlist!='')
		{
			$sql ="SELECT name,email,id from subscribers where id IN (".$idlist.")";
			$query = $this->db->query($sql);
			foreach ($query->result() as $row)
			{
				$data['name']=$row->name;
				$data['email']=$row->email;
			
				$this->email->clear();
				$this->email->from('info@ideabox.com.au', 'Ideabox Newsletter');
				$this->email->to($data['email']);
				$this->email->subject($title);
				
				ob_start();
		
				$this->load->view('email-template',$data);
				$body2 = ob_get_contents();
				ob_end_clean();
				$this->email->message($body2);			
				$this->email->send();
			}
		}
		//session_start(); 
		//$_SESSION['message']='<div id="flashmessage">Mail has been sent succesfully to all subscribers</div>';
		$this->session->set_flashdata('message', '<div style="color:red"><h4>Mail has been sent succesfully to all subscribers</h4><br></div>');
		redirect("/adminpage/cpanel/mailtemplate/");
	}
// DOWNLOAD ===================	
	function downloadmanager()
	{
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/downloadmanager/';
		$config['per_page'] = 10;//$this->config->item('item_per_page');
		$config['uri_segment'] = 4; 
		$config['total_rows'] =$this->general_model->get_download_manager('totalrows');
		$this->pagination->initialize($config);
		$result=$this->general_model->get_download_manager('',$config['per_page'],$this->uri->segment(4));
		$temp=array();
			if($result->num_rows()>0)
			{
				$temp=$result->result_array();
			}
		$alldata['banners']=$temp;		
		$alldata['all_link']=$this->pagination->create_links();
		
		$result=$this->general_model->get_category(1);	
		$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
		$alldata['category']=$_data;
		
		$data['content']=$this->load->view('download',$alldata,true);

		$this->load->view('template',$data);
		
			
	}
	function editdownload($id='')
	{
		if($id!='')
		{
			$data['id']=$id; // update
			$result=$this->general_model->get_download_detail($id);	
				
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['banners']=$_data;	
		}
		else
		{
			$data['id']=''; // add new
		}
		$result=$this->general_model->get_category(1);	
		$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
		$data['category']=$_data;
		$data['content']=$this->load->view('editdownload',$data,true);
		$this->load->view('template',$data);
	}
	// ADD or UPDATE ACTION
	function download_manipulate()
	{
		if ($this->general_model->download_manipulate($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/downloadmanager/");
	}
	function deletedownload($id=0)
	{
		$this->db->trans_start(); 
		$this->db->delete('download', array('id' => $id));
		$this->db->delete('download_description', array('download_id' => $id));
		$this->db->trans_complete();
		redirect("/adminpage/cpanel/downloadmanager/");
	}
// NEWS ===================	
	function newsmanager()
	{
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/newsmanager/';
		$config['per_page'] = 10;//$this->config->item('item_per_page');
		$config['uri_segment'] = 4; 
		$config['total_rows'] =$this->general_model->get_newsmanager('totalrows');
		$this->pagination->initialize($config);
		$result=$this->general_model->get_newsmanager('',$config['per_page'],$this->uri->segment(4));
		$temp=array();
			if($result->num_rows()>0)
			{
				$temp=$result->result_array();
			}
		$alldata['banners']=$temp;		
		$alldata['all_link']=$this->pagination->create_links();
		
		$data['content']=$this->load->view('news',$alldata,true);

		$this->load->view('template',$data);
		
			
	}
	function editnews($id='')
	{
		if($id!='')
		{
			$data['id']=$id; // update
			$result=$this->general_model->get_news_detail($id);	
				
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['banners']=$_data;	
		}
		else
		{
			$data['id']=''; // add new
		}

		$data['content']=$this->load->view('editnews',$data,true);
		$this->load->view('template',$data);
	}
	// ADD or UPDATE ACTION
	function news_manipulate()
	{
		if ($this->general_model->news_manipulate($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/newsmanager/");
	}
	function deletenews($id=0)
	{
		$this->db->trans_start(); 
		$this->db->delete('article', array('id' => $id));
		$this->db->delete('article_description', array('article_id' => $id));
		$this->db->trans_complete();
		redirect("/adminpage/cpanel/newsmanager/");
	}

// =============== INFORMATIONS ========================

function information($alias)
	{

		$result_faq_manager=$this->general_model->get_information($alias);
		$faq_manager=array();
		if($result_faq_manager->num_rows()>0)
		{
			$faq_manager=$result_faq_manager->result_array();

		}
		$_faqdata['banners']=$faq_manager;
		$data['content']=$this->load->view('editinformation',$_faqdata,true);
		$this->load->view('template',$data);
	}
	function information_manipulate()
	{
		//echo strtotime($_POST['txtStartDate']);
		//die;
		if ($this->general_model->information_manipulate($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/information/".$_POST['alias']);
	}
	
// ============ EVENTS ===================	
	function eventsmanager()
	{
		//echo strtotime("05-13-2011","%m-%d-%Y");
		//echo strtotime("05/16/2011");
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/eventsmanager/';
		$config['per_page'] = 10;//$this->config->item('item_per_page');
		$config['uri_segment'] = 4; 
		$config['total_rows'] =$this->general_model->get_eventsmanager('totalrows');
		$this->pagination->initialize($config);
		$result=$this->general_model->get_eventsmanager('',$config['per_page'],$this->uri->segment(4));
		$temp=array();
			if($result->num_rows()>0)
			{
				$temp=$result->result_array();
			}
		$alldata['banners']=$temp;		
		$alldata['all_link']=$this->pagination->create_links();
		
		$data['content']=$this->load->view('events',$alldata,true);

		$this->load->view('template',$data);
		
			
	}
	function editevents($id='')
	{
		if($id!='')
		{
			$data['id']=$id; // update
			$result=$this->general_model->get_events_detail($id);	
				
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['banners']=$_data;	
			
			$result=$this->general_model->get_events_gallery($id);	
				
			$_data=array();
			if($result->num_rows()>0)
			{
				$_data=$result->result_array();
			}
			$data['gallery']=$_data;
		}
		else
		{
			$data['id']=''; // add new
		}

		$data['content']=$this->load->view('editevents',$data,true);
		$this->load->view('template',$data);
	}
	// ADD or UPDATE ACTION
	function events_manipulate()
	{
		//echo strtotime($_POST['txtStartDate']);
		//die;
		if ($this->general_model->events_manipulate($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/eventsmanager/");
	}
	function deleteevents($id=0)
	{
		$this->db->trans_start(); 
		$this->db->delete('events', array('id' => $id));
		$this->db->delete('events_description', array('events_id' => $id));
		$this->db->delete('gallery', array('reference_id' => $id));
		$this->db->trans_complete();
		redirect("/adminpage/cpanel/eventsmanager/");
	}
	
///  SETTING ====================
	function changepassword()
	{
		if($_POST)
		{
			if($_POST['pass']!=$_POST['confirmpass'])
			{
				$data['error']="Password didn't match, please try again";
				$data['content']=$this->load->view('changepassword',$data,true);
				$this->load->view('template',$data);
			}
			else
			{
				$sql = "update admin set password='".md5($_POST['pass'])."'";
				//echo md5($_POST['pass']);
		 		$this->db->query($sql);
				unset($_SESSION['logged_in_status']);
	    		redirect('/admin/');
			}
			
		}
		else
		{
			$data['content']=$this->load->view('changepassword','',true);
			$this->load->view('template',$data);
		}
	}
	function globalconfig()
	{
		$data['icon']="icon-48-job-changepass.png";
		$data['title']="Global Config";

		$data['content']=$this->load->view('globalconfig','',true);
		$this->load->view('template',$data);
	}
	
	function gallery_manager()
	{
		$data['icon']="icon-48-media.png";
		$data['title']="Albums manager";
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/gallery_manager/';
		$config['total_rows'] =$this->general_model->get_gallery_manager('totalrow','','');
		$config['per_page'] =10;
		$config['uri_segment'] = 4; 
		$this->pagination->initialize($config);
		$_newsletter=array();
		$result_newsletter=$this->general_model->get_gallery_manager('',$config['per_page'],$this->uri->segment(4));
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['gallery_manager']=$result_newsletter->result_array();
		}
		//var_dump($result_newsletter);
		$data['content']=$this->load->view('gallery_manager',$_newsletter,true);
		$this->load->view('template',$data);
	}
	function album($id)
	{
		$data['icon']="icon-48-media.png";
		$result_name=$this->general_model->get_albumName($id);
		$name='';
		if($result_name->num_rows()>0)
		{
			$_name=$result_name->result_array();
			$name=$_name[0]['created_date'];
		}
		
		if($name!='')
		{
			$name=myfull_int_date($name);
		}
		
		$data['title']="Albums ".$name;
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/album/'.$id."/";
		$config['total_rows'] =$this->general_model->get_album($id,'totalrow','','');
		$config['per_page'] =20;
		$config['uri_segment'] = 5; 
		$this->pagination->initialize($config);
		$_newsletter=array();
		$result_newsletter=$this->general_model->get_album($id,'',$config['per_page'],$this->uri->segment(5));
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['album_manager']=$result_newsletter->result_array();
		}
		$_newsletter['album_id']=$id;
		//var_dump($result_newsletter);
		$data['content']=$this->load->view('album_manager',$_newsletter,true);
		$this->load->view('template',$data);
	}
	function add_gallery()
	{
		if ($this->general_model->add_gallery($_POST))
		{
			//$this->export_xml();
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect($_POST['myurl']);
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect($_POST['myurl']);
		}
	}
	function add_image()
	{
		$this->db->trans_start(); 
		$this->load->helper(array('form', 'url'));
		
		$config['upload_path'] = './upload/gallery/';
		$config['allowed_types'] = 'gif|jpg|jpeg|png';
		$config['max_size']	= '2000';
		$config['encrypt_name']	=TRUE;    // rename to random string
		
		$this->load->library('upload', $config);
			
		//if (!empty($_FILES['Filedata']['name']))
		//{
			if ( $this->upload->do_upload("Filedata"))
			{	
					$datax=$this->upload->data();
					$this->db->set('image',$datax['file_name']);
					$this->db->set('album_id',$_POST['albumid']);
					$this->db->insert('gallery'); 
					$sql ="update album set total_item=total_item+1 where id=".$_POST['albumid'];
					$this->db->query($sql);
					
			}
		//}
		$this->db->trans_complete();
		if ($this->db->trans_status() == FALSE)
		{
			echo "0"; // must print something to make it work
		} 
		else
		{
			echo "1"; // must print something to make it work
		}
	}
	function delete_gallery($detail_id)
	{
		if ($this->general_model->delete_gallery($detail_id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/gallery_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/gallery_manager/");
		}

	}
	function delete_image($id,$album_id)
	{
		if ($this->general_model->delete_image($id,$album_id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			
		}
		redirect("/adminpage/cpanel/album/".$album_id);

	}
//=============== SLIDESHOW IMAGES IN HOMEPAGE
	function slideshow()
	{
		$data['icon']="icon-48-media.png";
		$data['title']='Slideshow';
		
		$slidehow=array();
		$result_slidehow=$this->general_model->get_slideshow();
		if($result_slidehow->num_rows()>0)
		{
			$slidehow=$result_slidehow->result_array();
		}
		$_menudata['slideshow']=$slidehow;
		$data['content']=$this->load->view('slideshow',$_menudata,true);
		$this->load->view('template',$data);
	}
	function add_slideshow()
	{
		if ($this->general_model->add_slideshow($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/slideshow/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/slideshow/");
		}
	}
	function delete_slideshow($id)
	{
		if ($this->general_model->delete_slideshow($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/slideshow/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/slideshow/");
		}

	}	
// ==============================
 function news_edit($id=0)
    {
        $data['icon']="icon-48-article.png";
        if($id==14){
            $data['title']="Floors Manager";
        }
        else if($id==15){
            $data['title']="Baerenders Manager";
        }
        else if($id==16){
            $data['title']="Deejays Manager";
        }
        
        
         $_newsletter= array();
   	    
        if((int)$id)
        {
            $editcontent=$this->general_model->get_article_detail1($id);

            $_newsletter['editcontent']=$editcontent;
            $_newsletter['current_id']=$id;
        }
	   $data['content']=$this->load->view('news_edit',$_newsletter,true);
	   $this->load->view('template',$data);
    }	

	function update_article()
	{
            if ($this->general_model->update_news($_POST))
		      {
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		
            }
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}
            redirect("/adminpage/cpanel/news_edit/".$_POST['id']);
	}
// ========================== VIP TABLE=========================	
	
	function reservations_manager()
	{
		$data['icon']="icon-48-cv-manager.png";
		$data['title']="VIP Table Manager";
		if (isset($_POST['search_option']))
		{
			$this->session->set_userdata('search_option_cv',$_POST['search_option']);
		}
		if (isset($_POST['keyword']))
		{
			$this->session->set_userdata('keyword_cv',$_POST['keyword']);
		}

		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/reservations_manager/';
		$config['total_rows'] =$this->general_model->get_reservations('totalrow',$this->session->userdata('search_option_cv'),$this->session->userdata('keyword_cv'),'','');
		$config['per_page'] = 6;
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		//$segment=$this->uri->segment(4, 0);		// asign= 0 if NOT found
		$result_reservations=$this->general_model->get_reservations('',$this->session->userdata('search_option_cv'),$this->session->userdata('keyword_cv'),$config['per_page'],$this->uri->segment(4));
		
		$reservations=array(); //  incase NO RECORD found
		
		if($result_reservations->num_rows()>0)
		{
			$reservations=$result_reservations->result_array();
		}
		$_data['reservations']=$result_reservations->result_array();
		$data['content']=$this->load->view('reservation_manager',$_data,true);
		//var_dump ($_videodata);
		$this->load->view('template',$data);
	}
	function delete_reserve($id)
	{
		if ($this->general_model->delete_reserve($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/reservations_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/reservations_manager/");
		}

	
	}
	function show_status_reserve($id,$status)
	{
		$data['id']=$id;
		$data['status']=$status;
		$this->load->view('popup_edit_reserve',$data);
	}
	function update_status_reserve()
	{
		if ($this->general_model->update_status_reserve($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/reservations_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/reservations_manager/");
		}

	}	
	
// ================== BOOKING MANAGER ======================
	function booking_manager()
	{
		$data['icon']="icon-48-cv-manager.png";
		$data['title']="Booking Manager";
		if (isset($_POST['search_option']))
		{
			$this->session->set_userdata('search_option_booking',$_POST['search_option']);
		}
		if (isset($_POST['keyword']))
		{
			$this->session->set_userdata('keyword_booking',$_POST['keyword']);
		}

		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/booking_manager/';
		$config['total_rows'] =$this->general_model->get_booking('totalrow',$this->session->userdata('search_option_booking'),$this->session->userdata('keyword_booking'),'','');
		$config['per_page'] = 6;
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		//$segment=$this->uri->segment(4, 0);		// asign= 0 if NOT found
		$result_reservations=$this->general_model->get_booking('',$this->session->userdata('search_option_booking'),$this->session->userdata('keyword_booking'),$config['per_page'],$this->uri->segment(4));
		
		$reservations=array(); //  incase NO RECORD found
		
		if($result_reservations->num_rows()>0)
		{
			$reservations=$result_reservations->result_array();
		}
		$_data['reservations']=$result_reservations->result_array();
		$data['content']=$this->load->view('booking_manager',$_data,true);
		//var_dump ($_videodata);
		$this->load->view('template',$data);
	}
	function delete_booking($id)
	{
		if ($this->general_model->delete_booking($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/booking_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/booking_manager/");
		}

	
	}
	function show_status_booking($id,$status)
	{
		$data['id']=$id;
		$data['status']=$status;
		$this->load->view('popup_edit_booking',$data);
	}
	function update_status_booking()
	{
		if ($this->general_model->update_status_booking($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/booking_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/booking_manager/");
		}

	}	
	
//========================= USER MANAGER =============================

	function user_manager()
	{
		$data['icon']="icon-48-user.png";
		$data['title']="User Manager";
		if (isset($_POST['search_option']))
		{
			$this->session->set_userdata('search_option_user',$_POST['search_option']);
		}
		if (isset($_POST['keyword']))
		{
			$this->session->set_userdata('keyword_user',$_POST['keyword']);
		}

		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/user_manager/';
		$config['total_rows'] =$this->general_model->get_user_manager('totalrow',$this->session->userdata('search_option_user'),$this->session->userdata('keyword_user'),'','');
		$config['per_page'] = 20;
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		//$segment=$this->uri->segment(4, 0);		// asign= 0 if NOT found
		$result_reservations=$this->general_model->get_user_manager('',$this->session->userdata('search_option_user'),$this->session->userdata('keyword_user'),$config['per_page'],$this->uri->segment(4));
		
		$reservations=array(); //  incase NO RECORD found
		
		if($result_reservations->num_rows()>0)
		{
			$reservations=$result_reservations->result_array();
		}
		$_data['users']=$result_reservations->result_array();
		$data['content']=$this->load->view('user_manager',$_data,true);
		//var_dump ($_videodata);
		$this->load->view('template',$data);
	}
	function delete_user($id)
	{
		if ($this->general_model->delete_user($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/user_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/user_manager/");
		}

	
	}
	function show_status_user($id,$status)
	{
		$data['id']=$id;
		$data['status']=$status;
		$this->load->view('popup_edit_user',$data);
	}
	function update_status_user()
	{
		if ($this->general_model->update_status_user($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/user_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/user_manager/");
		}

	}
	
//================	 OLD =========================
/*	function export_xml()
	{
		if ($this->general_model->export_xml())
		{
				return 1;
		}
		else
		{
			return 0;
		}

	}
	function newsletter()
	{
		$data['icon']="icon-48-newsletter.png";
		$data['title']="Newsletter";
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/newsletter/';
		$config['total_rows'] =$this->general_model->get_newsletter('totalrow','','');
		$config['per_page'] =20;
		$config['uri_segment'] = 4; 
		$this->pagination->initialize($config);
		$_newsletter=array();
		$result_newsletter=$this->general_model->get_newsletter('',$config['per_page'],$this->uri->segment(4));
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['newsletter']=$result_newsletter->result_array();
		}
		//var_dump($result_newsletter);
		$data['content']=$this->load->view('newletter',$_newsletter,true);
		$this->load->view('template',$data);
	}
	
	function delete_newsletter($id)
	{
		
		if ($this->general_model->delete_newsletter($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/newsletter/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/newsletter/");
		}
	}

	function sendmail_newsletter()
	{
		
		if ($this->general_model->sendmail_newsletter($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/newsletter/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/newsletter/");
		}
	}
// =================== FAQ MANAGER ============	

	function faq()
	{
		$data['icon']="icon-48-faq.png";
		$data['title']="FAQ";
		$result_faq_manager=$this->general_model->get_faq_manager_all(2);
		$faq_manager=array();
		if($result_faq_manager->num_rows()>0)
		{
			$faq_manager=$result_faq_manager->result_array();

		}
		$_faqdata['faq_manager']=$faq_manager;
		$_faqdata['is_company']='';
		$_faqdata['is_jobseeker']='';
		$data['content']=$this->load->view('faq_manager',$_faqdata,true);
		$this->load->view('template',$data);
	}

	function delete_faq($id)
	{
		if ($this->general_model->delete_faq($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/faq/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/faq/");
		}
	}
// ======== REVIEWS MANAGER =================

	function reviews_manager()
	{
		$data['icon']="icon-48-article.png";
		$data['title']="REVIEWS";
		$result_faq_manager=$this->general_model->get_faq_manager_all(1);
		$faq_manager=array();
		if($result_faq_manager->num_rows()>0)
		{
			$faq_manager=$result_faq_manager->result_array();

		}
		$_faqdata['faq_manager']=$faq_manager;
		$data['content']=$this->load->view('reviews_manager',$_faqdata,true);
		$this->load->view('template',$data);
	}

	function delete_reviews($id)
	{
		if ($this->general_model->delete_faq($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/reviews_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/reviews_manager/");
		}
	}


	function behandling_manager()
	{
		$data['icon']="icon-48-article.png";
		$data['title']="Behandling";
		
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/behandling_manager/';
		$config['total_rows'] =$this->general_model->get_totalrow_article(1);
		$config['per_page'] =10;
		//echo $config['per_page'];
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		
		$result_newsletter=$this->general_model->get_all_article(1,$config['per_page'],$this->uri->segment(4));
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['newsletter']=$result_newsletter->result_array();
		}
		
		$data['content']=$this->load->view('behandling_manager',$_newsletter,true);
		$this->load->view('template',$data);

	}
    
   	function news_manager($id=0)
	{
	   
		$data['icon']="icon-48-article.png";
		$data['title']="News";
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/news_manager/';
		$config['total_rows'] =$this->general_model->get_totalrow_article(2);
		$config['per_page'] =10;
		//echo $config['per_page'];
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		
		$result_newsletter=$this->general_model->get_all_article(2,$config['per_page'],$this->uri->segment(4));
        $cats=$this->general_model->get_catelogies();
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['newsletter']=$result_newsletter->result_array();
		}
        
        if($cats->num_rows()>0)
        {
            $_newsletter['cats']=$cats->result_array();    
        }
        
		$data['content']=$this->load->view('news_manager',$_newsletter,true);
  
		$this->load->view('template',$data);

	}
    
   	function price_manager()
	{
	   
		$data['icon']="icon-48-article.png";
		$data['title']="Prices manager";
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/price_manager/';
		$config['total_rows'] =$this->general_model->get_totalrow_price();
		$config['per_page'] =10;
		//echo $config['per_page'];
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		
		$result_newsletter=$this->general_model->get_all_price(2,$config['per_page'],$this->uri->segment(4));
        //$cats=$this->general_model->get_catelogies();
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['newsletter']=$result_newsletter->result_array();
		}
 
        
        $pageinfor=$this->general_model->get_page_title(2);
        $_newsletter['pageinfor']=$pageinfor;
		$data['content']=$this->load->view('price_manager',$_newsletter,true);
  
		$this->load->view('template',$data);

	}
    
    	function axamfodfodplejere($id=0)
	{
	   
		$data['icon']="icon-48-article.png";
		$data['title']="Exam fodplejere";
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/axamfodfodplejere/';
		$config['total_rows'] =$this->general_model->get_totalrow_article(3);
		$config['per_page'] =10;
		//echo $config['per_page'];
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		
		$result_newsletter=$this->general_model->get_all_article(3,$config['per_page'],$this->uri->segment(4));
		if($result_newsletter->num_rows()>0)
		{
		  $_newsletter['type']=1;
			$_newsletter['newsletter']=$result_newsletter->result_array();
		}
        
        
		$data['content']=$this->load->view('axamfodfodplejere',$_newsletter,true);
  
		$this->load->view('template',$data);

	}
*/    
/*   function behandling_manager($id=0)
	{
	   
		$data['icon']="icon-48-article.png";
		$data['title']="Behandling";
		$_newsletter= array();
		$this->load->library('pagination');
		$config['base_url'] = base_url().index_page().'/adminpage/cpanel/behandling_manager/';
		$config['total_rows'] =$this->general_model->get_totalrow_article(1);
		$config['per_page'] =10;
		//echo $config['per_page'];
		$config['uri_segment'] = 4; 
		//echo $config['total_rows'];
		$this->pagination->initialize($config);
		
		$result_newsletter=$this->general_model->get_all_article(1,$config['per_page'],$this->uri->segment(4));
		if($result_newsletter->num_rows()>0)
		{
			$_newsletter['newsletter']=$result_newsletter->result_array();
            $_newsletter['type']=1;
		}
        
        
		$data['content']=$this->load->view('axamfodfodplejere',$_newsletter,true);
  
		$this->load->view('template',$data);

	}
*/    
/*    function news_edit($id=0)
    {
        $data['icon']="icon-48-article.png";
        if($id==23)
		$data['title']="Fodpleje";
        else
        if($id==36)
		$data['title']="Velkommen";
        else
        if($id==37)
		$data['title']="Vidste du at";
        else
        if($id==14)
		$data['title']="Om os";
        else
        $data['title']="Behandling";
         $_newsletter= array();
   	    if((int)$id)
        {
            $editcontent=$this->general_model->get_article_detail1($id);

            $_newsletter['editcontent']=$editcontent;
            $_newsletter['current_id']=$id;
        }
	   $data['content']=$this->load->view('news_edit',$_newsletter,true);
	   $this->load->view('template',$data);
    }
    
	function delete_search_job($id)
	{
		if ($this->general_model->delete_search_job($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/behandling_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/behandling_manager/");
		}
	}
    
    function delete_news($id)
	{
		if ($this->general_model->delete_search_job($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/news_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/news_manager/");
		}
	}
    
    function delete_axam($id)
	{
		if ($this->general_model->delete_search_job($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/axamfodfodplejere/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/axamfodfodplejere/");
		}
	}
    
    function delete_beha($id)
	{
		if ($this->general_model->delete_search_job($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/behandling_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/behandling_manager/");
		}
	}
    
    function delete_price($id)
    {
        if ($this->general_model->delete_price($id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/price_manager/");
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/price_manager/");
		}
    }
    
	function get_article_detail($id)
	{
		$result_article_detail=$this->general_model->get_article_detail($id);
		if($result_article_detail->num_rows()>0)
		{
			
			echo json_encode($result_article_detail->result_array());
		}
	}
    
    function get_price_detail($id)
	{
		$result_article_detail=$this->general_model->get_price_detail($id);
		if($result_article_detail->num_rows()>0)
		{
			
			echo json_encode($result_article_detail->result_array());
		}
	}

*/    

/*	function article_manipulate()
	{
		if ($_POST['option']=='add_article_item') // addnew
		{
			$this->add_article($_POST);
		}
		else // update
		{
			$this->update_article($_POST);			
		}
	}
	function add_article($arr)
	{
		
		if ($this->general_model->add_article(1,$arr))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/behandling_manager/");
	}
    
    function add_news()
	{
	   $arr=$_POST;
       if($_POST['behanding']==1)
       {
			if($arr['option']=='update_exam')
			{
				 if ($this->general_model->update_news($arr))
				{
					$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		
				}
				else
				{
					$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
				}
	
				redirect("/adminpage/cpanel/axamfodfodplejere/");
			}
			 else if($_POST['option']=='add_axam')
			   {
					if ($this->general_model->add_article(3,$arr))
					{
						$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
					}
					else
					{
						$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
					}
					redirect("/adminpage/cpanel/axamfodfodplejere/");
			   } 
			else
			{
				if ($this->general_model->add_article(1,$arr))
				{
					$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
				}
				else
				{
					$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
				}    
				redirect("/adminpage/cpanel/behandling_manager/");
			}
        
    		
       }
	   else if($_POST['option']=='add_news')
       {
            if ($this->general_model->add_article(2,$arr))
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
    		}
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}
    		redirect("/adminpage/cpanel/news_manager/");
       }
	   if($_POST['option']=='add_axam')
       {
        	if ($this->general_model->add_article(3,$arr))
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
    		}
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}
    		redirect("/adminpage/cpanel/axamfodfodplejere/");
       } 
	   else if($arr['option']=='update_exam')
        {
             if ($this->general_model->update_news($arr))
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		}
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}

            redirect("/adminpage/cpanel/axamfodfodplejere/");
        }
		else
       {
            if ($this->general_model->update_news($arr))
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		}
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}
    		 redirect("/adminpage/cpanel/news_manager/");
       }
		
		
	}
    
    function add_price(){
        
        if ($this->general_model->add_price($_POST))
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
    		}
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}
    		redirect("/adminpage/cpanel/price_manager/");
    }
    
	function update_article($arr)
	{
	   if(empty($arr['page']))
       {
        $arr['page']='';
       }
        if($arr['id']==23||$arr['id']==36||$arr['id']==37||$arr['id']==14)
        {

            if ($this->general_model->update_news($arr))
		      {
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		
            }
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}
        }else
        {
            if ($this->general_model->update_news($arr))
            {
			 $this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		}
    		else
    		{
    			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
    		}    
        }
		
        if($arr['id']==23||$arr['id']==36||$arr['id']==37||$arr['id']==14)
        {
            redirect("/adminpage/cpanel/news_edit/".$arr['id']);
        }else 
        if($arr['page']=='news')
        {
            redirect("/adminpage/cpanel/news_manager/");
        }else
		      redirect("/adminpage/cpanel/behandling_manager/");
	}*/




//  ============ HISTORY ==================

/*	function history()
	{
		$data['icon']="icon-48-article.png";
		$data['title']="HISTORY";
		$result_faq_manager=$this->general_model->get_information(1);
		$faq_manager=array();
		if($result_faq_manager->num_rows()>0)
		{
			$faq_manager=$result_faq_manager->result_array();

		}
		$_faqdata['information_manager']=$faq_manager;
		$data['content']=$this->load->view('information_manager',$_faqdata,true);
		$this->load->view('template',$data);
	}	
	function update_history()
	{
		if ($this->general_model->update_history($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	   		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		redirect("/adminpage/cpanel/price_manager/");
	}
*/	

//=============  MENU MANAGER ====================

/*	function menu_manager($id='')
	{
		$data['icon']="icon-48-menumgr.png";
		
			$data['title']="Catelogies";
			$job_category_manager=array();
			if ($id!='')
			{
				$result_job_category_manager=$this->general_model->get_menu_manager($id); // MENU ITEM in CATEGORY
			}
			else
			{
				$result_job_category_manager=$this->general_model->get_menu_manager('');// CATEGORY
			}
			if($result_job_category_manager->num_rows()>0)
			{
				
				$job_category_manager=$result_job_category_manager->result_array();
			}
			$_job_categorydata['menu_manager']=$job_category_manager;
			$data['content']=$this->load->view('menu_manager',$_job_categorydata,true);
				
		$this->load->view('template',$data);
	}	
	function addnew_menu()
	{
		if ($this->general_model->addnew_menu($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect($_POST['myurl']);
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect($_POST['myurl']);
		}
	}

	function delete_menu($id,$category_id='')
	{
		if ($this->general_model->delete_menu($id,$category_id))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
		}
		if ($category_id >0)
		{
			redirect("/adminpage/cpanel/menu_manager/".$category_id);
		}
		else
		{
			redirect("/adminpage/cpanel/menu_manager/");
		}

	}	
    
    
	

	function show_menu_detail($id,$category='')
	{
		$data['is_category']='';
		if ($category!='')
		{
			$result_edit_menu=$this->general_model->get_edit_menu_detail($id,$category); // MENU
			$data['is_category']=0;
		}
		else
		{
			$result_edit_menu=$this->general_model->get_edit_menu_detail($id); // CATEGORY
			$data['is_category']=1;
		}
		$data['edit_menu']=array();
		
		if($result_edit_menu->num_rows()>0)
		{
			$data['edit_menu']=$result_edit_menu->result_array();
		}
		//var_dump($result_edit_menu);
		$this->load->view('popup_edit_menu',$data);
	}
	function update_menu()
	{
		if ($this->general_model->update_menu($_POST))
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_success').'</div>');	    	
			redirect("adminpage/cpanel/menu_manager/".$_POST['is_category']);
		}
		else
		{
			$this->session->set_flashdata('message', '<div id="flashmessage">'.$this->lang->line('action_error').'</div>');
			redirect("/adminpage/cpanel/menu_manager/".$_POST['is_category']);
		}
	}
*/
}
